/*!
 * @file point3f.cpp
 * @brief Ciało point3f.hh
 */

#include "engine/basic/point3f.hh"
using namespace std;

/*--------------------------------------------------------------------------*/

point3f::point3f() :
	x(), y(), z() {

}

/*--------------------------------------------------------------------------*/

point3f::point3f(float x, float y, float z) :
	x(x), y(y), z(z) {
}

/*--------------------------------------------------------------------------*/

void point3f::normalize() {
	float length = sqrt(x * x + y * y + z * z);

	x = x / length;
	y = y / length;
	z = z / length;
}

/*--------------------------------------------------------------------------*/

point2f point3f::xz(){
	return point2f(x, z);
}

/*--------------------------------------------------------------------------*/

float point3f::length() {
	return sqrt(x * x + y * y + z * z);
}

/*--------------------------------------------------------------------------*/

ostream & operator <<(ostream & out, point3f & val) {
	out << "(" << val.x << "; " << val.y << "; " << val.z << ")" << endl;
	return out;
}

/*--------------------------------------------------------------------------*/

point3f operator +(point3f p1, point3f p2) {
	return point3f(p1.x + p2.x, p1.y + p2.y, p1.z + p2.z);
}

/*--------------------------------------------------------------------------*/

point3f operator -(point3f p1, point3f p2) {
	return point3f(p1.x - p2.x, p1.y - p2.y, p1.z - p2.z);
}

/*--------------------------------------------------------------------------*/

point3f operator *(point3f v, point3f w) {
	return point3f(v.y * w.z - v.z * w.y, v.z * w.x - v.x * w.z, v.x * w.y
			- v.y * w.x);
}

/*--------------------------------------------------------------------------*/

point3f operator *(point3f v, float w){
	return point3f(v.x * w, v.y * w, v.x * w);
}

/*--------------------------------------------------------------------------*/

point3f operator /(point3f v, float what) {
	return point3f(v.x / what, v.y / what, v.z / what);
}

/*--------------------------------------------------------------------------*/
